<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$act = UV::readMQ(strip_tags($route->POST("act")));
$userAs = UV::readMQ(strip_tags($route->POST("userAs")));
$messages = $route->POST("msg");
$user_id = $user->getUserId();

$message_list = "";
foreach ($messages as $key=>$message){
	$message_list .= "`message_id` = '$message'";
	if ($key < count($messages) - 1)
		$message_list .= " or ";
}

switch ($act)
{
	case "new": $query = "update `messages` set `read` = '0' where ($message_list) and `{$userAs}_id` = '$user_id'"; break;
	case "read":  $query = "update `messages` set `read` = '1' where ($message_list) and `{$userAs}_id` = '$user_id'"; break;
	case "delete":  $query = "update `messages` set `show_{$userAs}` = '0' where ($message_list) and `{$userAs}_id` = '$user_id'"; break;
}

$db->sendQuery($query);

?>
